package dong.common;

import org.springframework.beans.factory.FactoryBean;

/**
 * @author dongxing
 **/
public class UserFactoryBean<T> implements FactoryBean<T> {

    private Class<T> cls;

    private ProxyCreator proxyCreator;

    public UserFactoryBean(Class<T> cls, ProxyCreator proxyCreator) {
        this.cls = cls;
        this.proxyCreator = proxyCreator;
    }


    @Override
    public T getObject() throws Exception {
        return (T) proxyCreator.createProxy(getObjectType());
    }

    @Override
    public Class<?> getObjectType() {
        return cls;
    }
}
